<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>

        .box{
            width:200px;
            height:450px;
            border:1px solid red;
            margin:0 auto;
            padding:10px 10px 0;
        }
        .box img{
            width:200px;
            height:270px;
            background:url(images/2.jpg) no-repeat center /100% 100%;
            margin:0 auto;
        }
        .box h2{
            font-size: 12px;
            color:rgb(158, 149, 149);
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="./images/2.jpg" alt="">
        <h2>纪梵希 小羊皮口红403</h2>
        <p>
            价格：￥<span id="rich">340</span>
        </p>
        <p>
            数量
            <input id="num" type="number" min="0" value="0">
         
        </p>
        <p>
            总价：<span id="all">0</span>
        </p>

        <script>
            num.onchange = function(){
                all.innerHTML =(rich.innerHTML*1 * num.value*1).toFixed(2);
            }
        </script>
    </div>
    <!-- vertical-align -->
</body>
</html>